package per.turtle.system.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import per.turtle.common.core.annotation.MaxSizeWithCharset;
import per.turtle.common.core.web.entity.BaseEntity;
import per.turtle.common.excel.converters.BooleanStringConverter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @author turtle
 */
@ApiModel(value = "SysConfig", description = "系统配置")
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_config")
@ToString
public class SysConfig extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("参数主键")
    @ExcelProperty("参数主键")
    @TableId(type = IdType.AUTO)
    private Long configId;

    @ApiModelProperty("参数名称")
    @ExcelProperty("参数名称")
    @NotBlank(message = "参数名称不能为空")
    @MaxSizeWithCharset(max = 127, message = "参数名称超过限制长度！")
    private String configName;

    @ApiModelProperty("参数键名")
    @ExcelProperty("参数键名")
    @NotBlank(message = "参数键名长度不能为空")
    @Pattern(regexp = "[\\w]+", message = "参数键名仅支持输入字母，数字和下划线")
    @MaxSizeWithCharset(max = 63, message = "参数键名超过限制长度！")
    private String configKey;

    @ApiModelProperty("参数值")
    @ExcelProperty("参数值")
    @NotBlank(message = "参数值不能为空")
    @MaxSizeWithCharset(max = 255, message = "参数值超过限制长度！")
    private String configValue;

    @ApiModelProperty("系统内置")
    @ExcelProperty(value = "是否系统预设", converter = BooleanStringConverter.class)
    private Boolean isPreset;

}
